package userConsole.servlet;

import org.json.JSONException;
import org.json.JSONObject;
import userConsole.service.DeleteByIdService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Godv
 * @version 1.0
 */
@WebServlet("/deleteByIdServlet")
public class DeleteByIdServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        try {
            JSONObject jsonObject = new DeleteByIdService().deleteById(id);
            StaticPrint.print(resp, jsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
